package org.itsky.study.test4;

/**
 * @Author sky
 * @Site cmtianxie163.com 2020/4/16 10:37
 */
public class ThreadTest1 {
    public static void main(String[] args) {
        Thread t1 = new MyThread();
        t1.setName("线程一");
        t1.start();

        for (int i = 0; i < 200; i++) {
            if (i % 2 ==0){
                Thread.currentThread().setName("主线程");
                System.out.println(Thread.currentThread().getName() +  ": " + i);
            }
        }

    }
}



class MyThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 200; i++) {
            if (i % 2 ==0){
                System.out.println(getName() +  ": " + i);
            }
        }
    }
}